package sk.stuba.fiit.clientApp.gui.handler;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;
import javax.swing.JTable;

import sk.stuba.fiit.clientApp.gui.model.FileTableModel;

/**
 * Trieda zodpovedná za vymazania súboru z modelu tabuľky
 * @author Marek Hruška
 *
 */
public class RemoveButtonFileActionListener implements ActionListener {
	JTable table;
	
	public RemoveButtonFileActionListener(JTable table) {
		this.table = table;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		int row = table.getSelectedRow();
		if(row>=0){
			 ((FileTableModel)table.getModel()).removeFiles(row);
		}else{
			JOptionPane.showMessageDialog(null, "You did't choose any file", "Warning", JOptionPane.WARNING_MESSAGE);
			}		 
	}

}
